/*
 * Copyright 2011 Clean GWT
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
package com.cleangwt.bootstrap.client.style;

import com.google.gwt.user.client.ui.Widget;

/**
 * This class provides form control styles.
 * 
 * @author Jess
 * @version 1.0
 * @since 1.0
 */
public class Forms {
  public static final String INLINE_STYLE = "form-inline";
  public static final String HORIZONTAL_STYLE = "form-horizontal";
  public static final String FORM_GROUP_STYLE = "form-group";
  public static final String FORM_CONTROL_STYLE = "form-control";
  public static final String FORM_CONTROL_STATIC_STYLE = "form-control-static";
  public static final String CONTROL_LABEL_STYLE = "control-label";
  public static final String CHECKBOX_STYLE = "checkbox";
  public static final String CHECKBOX_INLINE_STYLE = "checkbox-inline";
  public static final String RADIO_STYLE = "radio";
  public static final String RADIO_INLINE_STYLE = "radio-inline";
  public static final String HELP_BLOCK_STYLE = "help-block";

  /**
   * The state style.
   */
  public static final String HAS_SUCCESS = "has-success";
  /**
   * The state style.
   */
  public static final String HAS_WARNING = "has-warning";
  /**
   * The state style.
   */
  public static final String HAS_ERROR = "has-error";

  /**
   * Adds {@link #HAS_SUCCESS} to the given widget and remove other state related style.
   * 
   * @param widget the widget
   * @return the widget itself
   */
  public static Widget success(Widget w) {
    w.removeStyleName(HAS_WARNING);
    w.removeStyleName(HAS_ERROR);
    w.addStyleName(HAS_SUCCESS);
    return w;
  }

  /**
   * Adds {@link #HAS_WARNING} to the given widget and remove other state related style.
   * 
   * @param widget the widget
   * @return the widget itself
   */
  public static Widget warning(Widget w) {
    w.removeStyleName(HAS_SUCCESS);
    w.removeStyleName(HAS_ERROR);
    w.addStyleName(HAS_WARNING);
    return w;
  }

  /**
   * Adds {@link #HAS_ERROR} to the given widget and remove other state related style.
   * 
   * @param widget the widget
   * @return the widget itself
   */
  public static Widget error(Widget w) {
    w.removeStyleName(HAS_SUCCESS);
    w.removeStyleName(HAS_WARNING);
    w.addStyleName(HAS_ERROR);
    return w;
  }

}
